<template>
  <!-- 黑名单维护审核明细-->
  <el-dialog
    :title="title"
    center
    :visible.sync="openState"
    width="1024px"
    :close-on-click-modal="false"
    :before-close="handleClose"
  >
    <el-form ref="form" :model="form" :rules="rules" :disabled="true" label-width="110px">
      <!--黑名单维护审核明细-->

      <el-row>
        <el-col :span="12">
          <el-form-item label="维护类型" prop="optype">
            <el-select v-model="form.optype" placeholder="维护类型" style="width: 100%">
              <el-option
                v-for="dict in dictMap.OP_TYPE"
                :key="dict.value"
                :label="`${dict.value}-${dict.text}`"
                :value="dict.value"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="来源" prop="source">
            <el-select v-model="form.source" placeholder="来源" style="width: 100%">
              <el-option
                v-for="dict in dictMap.DATE_SOURCE"
                :key="dict.value"
                :label="`${dict.value}-${dict.text}`"
                :value="dict.value"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="12">
          <el-form-item label="类型" prop="fileType">
            <el-select v-model="form.fileType" placeholder="类型" style="width: 100%">
              <el-option
                v-for="dict in dictMap.FILE_TYPE"
                :key="dict.value"
                :label="`${dict.value}-${dict.text}`"
                :value="dict.value"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="黑名单名称" prop="blacklistName">
            <el-input v-model="form.blacklistName" placeholder="黑名单名称" />
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="24">
          <el-form-item label="黑名单备注" prop="remarks">
            <el-input v-model="form.remarks" placeholder="黑名单备注" type="textarea" />
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="12">
          <el-form-item label="录入操作员" prop="mdTlrno">
            <el-input v-model="form.mdTlrno" placeholder="录入操作员" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="录入时间" prop="mdTime">
            <el-date-picker style="width: 100%" v-model="form.mdTime" value-format="yyyyMMddHHmmss" type="datetime" />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="approve">审 核</el-button>
      <el-button type="primary" @click="reject">拒 绝</el-button>
      <el-button @click="cancel">关闭</el-button>
    </div>
  </el-dialog>
</template>
<script>
import { blackListApproveDetail, blackListApprove, blackListReject } from "@/api/cnaps/bizMng/blackList.js";
import { listPageMixin } from "@/libs/listPageMixin";

export default {
  name: "blackListApproveDialog",
  mixins: [listPageMixin],
  components: {},
  data() {
    return {
      title: "",
      // 是否显示弹出层
      openState: false,
      // 字段可编辑控制

      //数据字典
      searchFormDictList: ["OP_TYPE", "DATE_SOURCE", "FILE_TYPE"],
      // 表单参数
      form: {},
      // 表单校验
      rules: {},
      opButtonList: () => {
        return [];
      },
    };
  },
  mounted() {},
  methods: {
    // 表单重置
    reset() {
      this.resetForm("form");
      this.$set(this, "form", {});
    },
    // 关闭回掉
    handleClose(done) {
      this.$confirm("确认关闭？")
        .then((_) => {
          this.reset();
          done();
        })
        .catch((_) => {});
    },
    show(row) {
      this.form = row;
      this.title = "黑名单维护审核明细";
      this.openState = true;

      this.blackListApproveDetail(row);
    },

    blackListApproveDetail: function (row) {
      blackListApproveDetail(row).then((response) => {
        this.showData(response);
      });
    },
    showData: function (response) {
      this.form = response.result.data;
    },

    /** TODO审批按钮 */
    approve() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          blackListApprove(this.form).then((res) => {
            if (res.code === "S") {
              this.msgSuccess("审批通过");
              this.cancel();
            }
          });
        }
      });
    },

    /** TODO拒绝按钮 */
    reject() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          blackListReject(this.form).then((res) => {
            if (res.code === "S") {
              this.msgSuccess("审批已拒绝");
              this.cancel();
            }
          });
        }
      });
    },

    cancel() {
      this.openState = false;
      this.reset();
      this.$emit("editComplete", true);
    },
  },
};
</script>
<style>
.label-header-msg {
  font-weight: bold;
}

.form-card {
  margin-bottom: 10px;
}
</style>
